package com.hch.maker.meta;

import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.json.JSONUtil;

/**
 * @author 86134
 * @version 1.0
 * @description TODO
 * @date 2024/7/24 20:03
 */

public class MetaManager {

    private static volatile Meta meta;

    public static Meta getMeta(){

        if(meta == null){
            synchronized (MetaManager.class){
                if(meta == null){
                    meta = initMeta();
                }
            }
        }
        return meta;
    }



    public static Meta initMeta(){
        String metaJson = ResourceUtil.readUtf8Str("meta.json");
        Meta meta = JSONUtil.toBean(metaJson, Meta.class);
        //todo 校验配置文件 ,处理默认值
        MetaValidator.doValidAndFill(meta);
//        System.out.println(meta);
        return meta;
    }

    public static void main(String[] args) {

    }
}
